package io.github.kuafucv.zero.log.core.io;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class IoUtils {

    public static long copy(InputStream in, OutputStream out) throws IOException {
        byte[] buffer = new byte[1024]; // 1k
        long totalSize = 0;
        while (true) {
            int size = in.read(buffer);
            if (size == -1) {
                return totalSize;
            }
            out.write(buffer, 0, size);
            totalSize += size;
        }
    }
}
